<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>为一个配置选项设置值</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ini-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ini_set</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ini_set</span> &mdash; <span class="dc-title">为一个配置选项设置值</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ini-set-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ini_set</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$varname</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$newvalue</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   设置指定配置选项的值。这个选项会在脚本运行时保持新的值，并在脚本结束时恢复。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ini-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">varname</code></dt>

     <dd>

      <p class="para">
      </p>
      <p class="para">
       不是所有有效的选项都能够用 <span class="function"><strong>ini_set()</strong></span> 来改变的。
       这里有个有效选项的清单<a href="ini.list.html" class="link">附录</a>。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">newvalue</code></dt>

     <dd>

      <p class="para">
       选项新的值。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ini-set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回旧的值，失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ini-set-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-516">
    <p><strong>Example #1 设置一个 ini 选项</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'display_errors'</span><span style="color: #007700">);<br /><br />if&nbsp;(!</span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'display_errors'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'display_errors'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'1'</span><span style="color: #007700">);<br />}<br /><br />echo&nbsp;</span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'display_errors'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ini-set-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="get_cfg_var.html" class="function" rel="rdfs-seeAlso">get_cfg_var()</a> - 获取 PHP 配置选项的值</span></li>
    <li class="member"><span class="function"><a href="ini_get.html" class="function" rel="rdfs-seeAlso">ini_get()</a> - 获取一个配置选项的值</span></li>
    <li class="member"><span class="function"><a href="ini_get_all.html" class="function" rel="rdfs-seeAlso">ini_get_all()</a> - 获取所有配置选项</span></li>
    <li class="member"><span class="function"><a href="ini_restore.html" class="function" rel="rdfs-seeAlso">ini_restore()</a> - 恢复配置选项的值</span></li>
    <li class="member">
     <a href="configuration.changes.html" class="link">如何改变配置选项</a>
    </li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>